
export function calculate(str){
    // 中文字判断
    var iTotal = 0;
    // 英文字母
    var eTotal = 0;
    for (var i = 0; i < str.length; i++) {
        var c = str.charAt(i);
        //基本汉字
        if (c.match(/[\u4e00-\u9fa5]/)) {
            // eslint-disable-next-line no-unused-vars
            iTotal++;
        }
        if (c.match(/[A-Za-z]+/)) {
            // eslint-disable-next-line no-unused-vars
            eTotal++;
        }
    }

    return (iTotal === 0?0:iTotal*13) + (eTotal === 0?0:eTotal*10)
}

export function setCommentLike(commentList,commentLikeUsers){
    if ((commentList === undefined || commentList.length <= 0) && (commentLikeUsers === undefined || commentLikeUsers.length <= 0)) return
    // 保存需要改变样式的 下标
    let changeIdList = []
    for (let i = 0; i < commentLikeUsers.length; i++) {
        for (let j = 0; j < commentList.length; j++) {
            if (commentLikeUsers[i].commentId === commentList[j].id){
                changeIdList.push(j)
            }
        }
    }
    return changeIdList
}
